﻿CREATE FUNCTION [dbo].[Get_InvIn_RegNum] ()
RETURNS int
AS
	BEGIN
	DECLARE @m_new_code int
	SELECT @m_new_code = MAX(REG_NUMBER) FROM INVOICE_IN
	RETURN 
		CASE 
			WHEN @m_new_code IS NULL THEN 100
			ELSE @m_new_code + 1
		END
	END
